<template>
  <div class="cs-tip-label" :class="labelType">
    <div id="triangle_right_top" :style="getTriangleColor_top"></div>
    <div id="triangle_right_bottom" :style="getTriangleColor_bottom"></div>
    <slot></slot>
  </div>
</template>

<script>
export default {
  props: {
    type: {
      type: String,
      default: 'danger'
    },
    triangleColor: {
      type: String,
      default: '#fff'
    }
  },
  computed: {
    labelType() {
      if (this.type === 'success') {
        return 'success'
      } else if (this.type === 'warning') {
        return 'warning'
      } else if (this.type === 'serious') {
        return 'serious'
      } else {
        return 'danger'
      }
    },
    getTriangleColor_top() {
      return `border-top-color: ${this.triangleColor};`
    },
    getTriangleColor_bottom() {
      return `border-bottom-color: ${this.triangleColor};`
    }
  }
}
</script>

<style scoped>
.cs-tip-label {
  position: relative;
  width: 85px;
  height: 26px;
  line-height: 26px;
  font-size: 12px;
  padding-left: 12px;
  color: #fff;
}

/* 右下角三角形 */
#triangle_right_bottom {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 0;
  right: 0;
  border-bottom: 13px solid;
  border-left: 13px solid transparent;
}
/* 右上角三角形 */
#triangle_right_top {
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  right: 0;
  border-top: 13px solid;
  border-left: 13px solid transparent;
}

.success {
  background-color: #00c952;
}

.warning {
  background-color: #f7b500;
}

.serious {
  background-color: #fa6400;
}

.danger {
  background-color: #e02020;
}
</style>
